﻿<%@ Page Title="" Language="C#" MasterPageFile="~/BackMaster2.Master" AutoEventWireup="true" CodeBehind="PRDetails_Show.aspx.cs" Inherits="BackStage.PRDetails_Show" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
         <script src="/BootstrapSouce/js/jquery.min.js"></script>
       <script src="BootstrapSouce/js/Command.js"></script>
   <%--   <script src="/BootstrapSouce/js/bootstrap.min.js"></script>
    <link href="/BootstrapSouce/css/bootstrap.min.css" rel="stylesheet" />--%>
    <script src="/Command.js"></script>
    <script>
        //首次加载
        $(function () { 
            Page(1);
            $("#sousuotable").hide();
        });
        var counttt = 0;
        //显示平台收益
        function Page(i) {
            $.getJSON("/Hand/PRDetails_Show.ashx", { pageindex: i, pagesize: 8, startime: $("#startime").val(), endtime: $("#endtime").val() }, function (data) {
                var msg = '<tr  style="background-color:#eddede" ><td>编号</td><td>入账金额</td><td>入账时间</td><td>入账款项</td></tr>';

                for (var s = 0; s < data.Data.length; s++) {
                    //转换时间格式
                    data.Data[s].PRDetailsInDatetime = data.Data[s].PRDetailsInDatetime.replace("/Date(", "").replace(")/", "");
                    if (data.Data[s].PRDetailsInDatetime.indexOf("+") > 0) {
                        data.Data[s].PRDetailsInDatetime = data.Data[s].PRDetailsInDatetime.substring(0, data.Data[s].PRDetailsInDatetime.indexOf("+"));
                    }
                    else if (data.Data[s].PRDetailsInDatetime.indexOf("-") > 0) {
                        data.Data[s].PRDetailsInDatetime = data.Data[s].PRDetailsInDatetime.substring(0, data.Data[s].PRDetailsInDatetime.indexOf("-"));
                    }
                    var date = new Date(parseInt(data.Data[s].PRDetailsInDatetime, 10));
                    var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
                    var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                    msg += "<tr><td>" + data.Data[s].PRDetailsId + "</td><td>" + data.Data[s].PRDetailsInMoney + "</td><td>" + date.getFullYear() + "-" + month + "-" + currentDate + "</td><td>" + data.Data[s].PRDetailsInTerm + "</td></tr>"
                }
                $.ajax({
                    type: "post",
                    url: "/Hand/PRDetails_SumMoney.ashx",
                    success: function (sumsmoney) {
                        $("#sumcount").html(sumsmoney);
                    }
                })
                $("#table_prdetails").html(msg);
                counttt = data.PageCount;
                //var tas = "<tr style='background-color:#eddede';><td><input id='sousuo' onclick='sousuoget()' type='button' value='筛选/搜索'/><span>共<label id='sums' style='display:inline-block'>" + data.PageCount + "</label>  页 &nbsp&nbsp&nbsp&nbsp当前第 <label id='index' style='display:inline-block'>" + data.PageIndex + "</label> 页&nbsp&nbsp&nbsp&nbsp <a onclick='Page(1)'>首页</a>&nbsp&nbsp&nbsp&nbsp";
                ////判断当前页是否为1，如果不是那就减一如果是那就直接定到第一页
                //if (data.PageIndex <= 1) {
                //    tas += ("<a  onclick='Page(1)'  >上一页</a>&nbsp&nbsp&nbsp&nbsp");
                //}
                //else {
                //    tas += ("<a  onclick='Page(" + (data.PageIndex - 1) + ")'  >上一页</a>&nbsp&nbsp&nbsp&nbsp");
                //}
                ////判断是否为最后一页。如果不是那就加一如果是那就直接定到最后一页
                //if (data.PageIndex >= data.PageCount) {
                //    tas += "<a  onclick='Page(" + (data.PageCount) + ")' >下一页</a>&nbsp&nbsp&nbsp&nbsp";
                //} else {
                //    tas += "<a  onclick='Page(" + (data.PageIndex + 1) + ")' >下一页</a>&nbsp&nbsp&nbsp&nbsp";
                //}
                //tas += " <a onclick='Page(" + data.PageCount + ")'>尾页</a>&nbsp&nbsp&nbsp&nbsp";

                ////跳转页
                //tas += "转到<input id='pageas' style='width:50px' type='text' /><input id='Button22' type='button'  onclick='tiaozhuan()'  value='确定' /></span>总金额：<span id='sumcount'></span>元</td> </tr>";
                //$("#tass").html(tas);
                var pager = "";
                pager += "<li style='float:right'><a> 当前第 " + data.PageIndex + " 页</a><a> 共" + data.PageCount + "页  </a><a>转到<input type='number' id='pageas' />页<input type='button' class='ben btn-primary' onclick='tiaozhuan()'  min='1'  value='确定'></a></li>";
                pager += "<li> <a href='#' onclick='Page(1)'>首页</a></li>";
                //判断当前页是否为1，如果不是那就减一如果是那就直接定到第一页
                if (data.PageIndex <= 1) {
                    pager += ("<li><a href='#'  onclick='Page(1)'  >上一页</a></li>");
                }
                else {
                    pager += ("<li><a href='#'  onclick='Page(" + (data.PageIndex - 1) + ")'  >上一页</a></li>");
                }
                //判断是否为最后一页。如果不是那就加一如果是那就直接定到最后一页
                if (data.PageIndex >= data.PageCount) {
                    pager += "<li><a  href='#' onclick='Page(" + (data.PageCount) + ")' >下一页</a></li>";
                } else {
                    pager += "<li><a  href='#' onclick='Page(" + (data.PageIndex + 1) + ")' >下一页</a></li>";
                }
                pager += " <li><a  href='#' onclick='Page(" + (data.PageCount) + ")'>尾页</a></li>";
                pager += "<li style='float:left'><a href='#' id='sousuo' onclick='sousuoget()'  >筛选</a><li>";
                $("#pager").html(pager);
            });
        };
        //跳转分页
        function tiaozhuan() {
            var idd = $("#pageas").val();
            if (idd > counttt) {
                alert("您输入的页数到达极限！为您跳转到尾页");
                Page(counttt);
            } else {
                Page(idd);
            }
        };
        //搜索
        function sousuoget() {
            $("#sousuotable").toggle();
            $("#startime").val("");//清空开始时间
            $("#endtime").val("");//清空结束时间
            Page(1);
        }
        function sousuos() {
            Page(1);
        }
    </script>
    <table class="table table-hover" id="sousuotable" style="margin-top: 50px; align-content:center; width:1000px;">
        <tr>
            <td>开始时间：</td>
            <td>
                <input id="startime" type="date" /><span style="color:red">只选开始时间则查询从开始时间往后所有</span></td></tr><tr>
            <td>结束时间：</td>
            <td>
                <input id="endtime" type="date" /><span style="color:red">只选结束时间则查询从结束时间往前所有</span></td>
            <td>&nbsp 
                <input id="Button1" type="button"  class="btn btn-primary"  onclick="sousuos()" value="搜索" /></td>
                <%--<input id="Button1" type="button" onclick="sousuos()" value="搜索" />--%>
           <%-- </td>--%>
        </tr>
    </table>
    <table class="table table-hover" id="table_prdetails">
    </table>
     <div><ul class="pager" id="pager">

       </ul></div>
    
    <table style="width: 1650px;" id="tass" class="table table-hover">
    </table>
</asp:Content>


